<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var p1=new Promise((resolve,reject)=>{
            setTimeout(function(){
                var num=Math.ceil(Math.random()*10);
                if(num>=5){
                    resolve(num+'num>=5');
                }else{
                    reject(num+'num<5');
                }
            },2000)

        })
        p1.then(function(data){
            //console.log(num);//num未声明，肯定会报错
            console.log('success-then',data)
        },function(data){
            console.log('error-then',data);
        }).catch(function(reason){
            console.log('reason:',reason);
        }).finally(function(){
            console.log('刷新操作')
        })
    </script>
</head>
<body>
    
</body>
</html>